/*
 * Copyright (C) 2012 Matthias Zeimer and the miniframes community.
 * All rights reserved. 
 * 
 * Licensed under the Eclipse Public License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.opensource.org/licenses/EPL-1.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.miniframes.minijpa;

import javax.persistence.PersistenceException;

/**
 * <p>
 * The transaction mode defines how transactions are required for a
 * {@linkplain DatabaseEnquiryMethod database enquiry method}.
 * </p>
 * 
 * @author Matthias Zeimer
 * @version 1
 * @since 0.1, 19.06.2012
 */
public enum TransactionMode {

    /**
     * Enquiry runs isolated in an own transaction. The transaction is opened
     * before the enquiry and commit afterwards if no exception has occurred.
     * The occurrence of a exception causes the transaction to be marked for
     * roll-back (an informative exceptions will not cause the transaction to be
     * marked for roll-back; see {@link PersistenceException} for details).
     */
    ISOLATED,

    /**
     * Enquiry requires an open transaction. This is the recommend mode.
     */
    REQUIRES_OPEN_TRANSACTION,

    /**
     * A transaction is not needed (but allowed). This is
     * <em>not</em> a recommend mode.
     */
    TRANSACTION_NOT_NEEDED;
    
    // TODO JTA !!! Siehe EntityManager#joinTransaction()
}
